package com.tanhua.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.model.db.Log;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Repository
public interface LogMapper extends BaseMapper<Log> {
   //根据日期和类型统计总数，
 @Select("select count(distinct user_id) from tb_log where type=#{type} and log_time = #{logTime}")
    Integer queryByTimeAndType(@Param("type") String type, @Param("logTime") String logTime);
   //根据日期统计总数
   @Select("select count(distinct user_id) from tb_log where log_time=#{logTime}")
    Integer queryByTime(String logTime);
  //统计次日留存数据
    @Select("select count(distinct user_id) from tb_log where log_time=#{today} and user_id in (\n" +
            "\t select user_id from tb_log where type='0102' and log_time=#{yesterday} \n"+")")
    Integer queryNumRetention1d(@Param("today") String today, @Param("yesterday") String yesterDay);
}
